package com.crr;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        CharacterFactory factory = new CharacterFactory();

        Character a = factory.getCharacter('A');
        Character b = factory.getCharacter('B');

        a.display('A', 10, 10);
        b.display('B', 20, 20);

        // 即使多次请求相同的字符，也不会创建新的对象
        Character anotherA = factory.getCharacter('A');
        Character anotherB= factory.getCharacter('B');
        System.out.println(a == anotherA); // 指向同一享元对象
        System.out.println(b == anotherB);

    }
}
